﻿/*****************************************************************//**
 * @file    FITKAcousticsVTKGraphObjectSEASubSystems.h
 * @brief   Graph object base for sub-system data.
 *  
 * @author  ChengHaotian (yeguangbaozi@foxmail.com)
 * @date    2024-11-15
 *********************************************************************/

#ifndef __FITKACOUSTICSVTKGRAPHOBJECTSEASUBSYSTEMS_H__
#define __FITKACOUSTICSVTKGRAPHOBJECTSEASUBSYSTEMS_H__

#include "FITKAcousticsVTKGraphObjectMergedData.h"
#include "FITKAcousticsVTKGraphAdaptorAPI.h"
#include "FITK_Component/FITKAcousticsModel/FITKAbstractSEASubSys.h"

// Forward declaration
class vtkCompositeDataGeometryFilter;

class FITKAcousticsVTKGraphActor;

namespace Acoustics
{
    class FITKAcousticsSEAModel;
    class FITKAbstractSEASubSys;
    class FITKAcousticsSEASubSysManager;
}

namespace Exchange
{
    class FITKAcousticsVTKGraphObjectSEASelectMergedData;
}

namespace Exchange
{
    /**
     * @brief   Graph object base for 'sub-system'.
     * @author  ChengHaotian (yeguangbaozi@foxmail.com)
     * @date    2024-11-15
     */
    class FITKACOUSTICSGRAPHADAPTORAPI FITKAcousticsVTKGraphObjectSEASubSystems : public FITKAcousticsVTKGraphObjectMergedData
    {
        // Regist
        FITKGraphObjectRegist(FITKAcousticsVTKGraphObjectSEASubSystems, FITKAcousticsVTKGraphObjectMergedData);
        FITKCLASS(Exchange, FITKAcousticsVTKGraphObjectSEASubSystems);

    public:
        /**
         * @brief   Constructor.
         * @param   seaModel: The SEA model data
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-15
         */
        FITKAcousticsVTKGraphObjectSEASubSystems(Acoustics::FITKAcousticsSEAModel* seaModel);

        /**
         * @brief   Destructor.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-15
         */
        virtual ~FITKAcousticsVTKGraphObjectSEASubSystems();

        /**
         * @brief   Update the visibility with data object's visibility.[virtual][override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-20
         */
        virtual void updateVisibility() override;

        /**
         * @brief   Update all graph actors by the given data id.[virtual][override]
         * @param   dataId: The data id need to be update
         * @param   forceUpdate: Force update[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-15
         */
        virtual void updateById(int dataId, bool forceUpdate = false) override;

        /**
         * @brief   Get the visibility from the data object.[virtual][override]
         * @return  The visibility
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-18
         */
        virtual bool getDataVisibility() override;

        /**
         * @brief   Get the shape id by the given shape type and VTK cell id.[virtual][override]
         * @param   vtkId: The VTK point or cell id in shape data
         * @param   topAbsShapeType: The shape type of the given ID( the same as TopAbs_ShapeEnum )
         * @return  The shape id
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-22
         */
        virtual int getShapeIdByVTKCellId(int vtkId, FITKAcousticsVTKCommons::ShapeMeshAbsEnum topAbsShapeType) override;

        /**
         * @brief   Save the post data dict.[virtual][override]
         * @param   arrayName: The array name of the post data
         * @param   data: The post data
         *          The key is the data object name.
         *          The value is the post value.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-21
         */
        virtual void setPostData(QString arrayName, QHash<QString, float> & data) override;

        /**
         * @brief   Update the color by the data color array in cell data.[virtual][override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-21
         */
        virtual void updateByDataColor() override;

        /**
         * @brief   Update the color by the post data for cell data.[virtual][override]
         * @param   arrayName: The data array name
         * @param   rangeMin: The min range for the look up table
         * @param   rangeMax: The max range for the look up table
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-21
         */
        virtual void updateByPostCellData(QString arrayName, double rangeMin, double rangeMax) override;

        /**
         * @brief   Update the color by the NULL post data for cell data.[virtual][override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-21
         */
        virtual void updateByPostNullData() override;

        /**
         * @brief   Enable or disbale log scale mode.[virtual][override]
         * @param   isOn: Enable or disable
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-28
         */
        virtual void setEnableLogScale(bool isOn) override;

    protected:
        /**
         * @brief   Intialize.[virtual][override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-20
         */
        virtual void init() override;

        /**
         * @brief   Get the visibility of SEA sub-system with runtime settings.
         * @return  The visibility
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-16
         */
        bool getGlobalSEASubSystemVisibility();

        /**
         * @brief   Generate the multi block dataset for the sub-systems.[virtual][override]
         * @return  Is the data valid
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-21
         */
        virtual bool generateDataSet() override;

        /**
         * @brief   Generate the actor with the sub-system data.[virtual][override]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-20
         */
        virtual void generateGraph() override;

    protected:
        /**
         * @brief   The SEA sub-system manager.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-20
         */
        Acoustics::FITKAcousticsSEASubSysManager* m_SEASubSysMgr{ nullptr };
        /**
         * @brief  子系统类型
         * @author BaGuijun (baguijun@163.com)
         * @date   2024-12-27
         */
        Acoustics::FITKAbstractSEASubSys::SEASubSysType m_SEASubSysTypeEnum = Acoustics::FITKAbstractSEASubSys::SEASSNone;

        /**
         * @brief   The filter for merging multi block dataset of boundary lines.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        vtkCompositeDataGeometryFilter* m_comp2PolyLine{ nullptr };
        /**
         * @brief  当前显示的数据组（是全部数据的子集）
         * @author BaGuijun (baguijun@163.com)
         * @date   2024-12-25
         */
        vtkMultiBlockDataSet* m_multiBlockDataSetLine = nullptr;
        /**
         * @brief   The filter for extracting the blocks of the multi block dataset.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-20
         */
        vtkExtractBlock* m_extractBlockLine{ nullptr };

        /**
         * @brief   The actor for the boundary lines.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-19
         */
        FITKAcousticsVTKGraphActor* m_fActorLine{ nullptr };

        /**
         * @brief   The number of valid data count.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-11-22
         */
        int m_validDataValueNum = 0;

    };
}   // namespace Exchange

#endif // __FITKACOUSTICSVTKGRAPHOBJECTSEASUBSYSTEMS_H__
